package com.ccs.demo;


import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@RequestMapping("/user")
@RestController
public class RequestControllerNew1 {
    @RequestMapping("/r1")
    public String r1(String name){
        return name;
    }

    @RequestMapping("/r2")
    public Integer r2(Integer age){
        return age;
    }

    @RequestMapping("/3")
    public String r3(int age){
        return "接收到参数："+age;
    }

    @RequestMapping("/4")
    public String r4(String name,int age){
        return "name :"+ name + " age:"+age;
    }

    @RequestMapping("/r5")
    public String r5(PersonNew personNew){
        return personNew.toString();
    }

    @RequestMapping("/r6")
    public String r6(@RequestParam(value = "n",required = false) String name){
        return name;
    }

    @RequestMapping("/r7")
    public String r7(@RequestParam String name,@RequestParam int age){
        return  "name :"+ name + " age:"+age;
    }

    @RequestMapping("/r8")
    public List<String> r8(@RequestParam List<String> name){
        return name;
    }

    @RequestMapping("/r9")
    public PersonNew r9(@RequestBody PersonNew personNew){
        return personNew;
    }

    @RequestMapping("/10/{articleId}")
    public Integer r10(@PathVariable Integer articleId){
        return articleId;
    }

    @RequestMapping("/10/{articleId}/{type}")
    public String r11(@PathVariable("id") Integer articleId,@PathVariable("t") String type){
        return "articleId: "+ articleId + "type:"+ type;
    }

    @RequestMapping("/r12")
    public String r12(@RequestPart MultipartFile file){
        return "接收到文件：" +
        file.getName() + "/n" + file.getOriginalFilename() + "/n" + file.getContentType();
    }
}
